package parameter.crop;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Calendar;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import dao.MyDAO;
import parameter.Calendar1;
import util.TipsTextField;

public class AutoTraCrop1 extends JFrame{
	private static JTextField textField_0; // 萎焉点基质势值
	private static JTextField textField_1;// 种植日期年值
	private static JTextField textField_2;// 最适土壤水基质势上限值
	private static JTextField textField_3;// 最适土壤水基质势下限值
	private static JTextField textField_4;// 土壤水分胁迫函数形参值
	private static JTextField textField_5;// 最大扎根深度a值
	//static JComboBox comboBox = new JComboBox();// 作物种类值选择
	private static JTextField textField_6;// 最大扎根深度b值
	private static JTextField textField_7;// 最大扎根深度c值
	static int flag = 0;// flag=0证明数据库有这个作物，不用插入
	static Crop crop = new Crop();
	static SoilWxp soilWxp = new SoilWxp();
	static Cropkind cropkind =new Cropkind();
	private static JTextField textField;// 土壤水渗透上限值
	private static JTextField textField_10;// 土壤水渗透下限值
	private static JTextField textField_11;// //土壤盐分胁迫函数形参X值
	private static JTextField textField_12;// 相对根长密度分布参数S值
	
	public static void main(String[] args) throws SQLException {
		new AutoTraCrop1();
	}
	public AutoTraCrop1() throws SQLException {
		// TODO Auto-generated constructor stub
		JFrame frame = new JFrame();
		frame.getContentPane().setFont(new Font("宋体", Font.PLAIN, 12));
				
				frame.getContentPane().setEnabled(false);
				frame.getContentPane().setBackground(SystemColor.text);
		    	GridBagLayout gridBagLayout = new GridBagLayout();
				gridBagLayout.columnWidths = new int[] {30, 0, 0, 0, 0, 30, 30, 30};
				gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
				gridBagLayout.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0};
				gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
				frame.getContentPane().setLayout(gridBagLayout);
				frame.setSize(700, 600);
				//题目标签
				JLabel label = new JLabel("\u81EA\u52A8\u704C\u6E89\u63A7\u5236\u6839\u533A\u7B97\u672F\u5E73\u5747\u6CD5\u571F\u58E4\u6C34\u5206\u4F20\u611F\u5668");
				label.setFont(new Font("宋体", Font.PLAIN, 12));
				GridBagConstraints gbc_label = new GridBagConstraints();
				gbc_label.insets = new Insets(0, 0, 5, 5);
				gbc_label.gridx = 3;
				gbc_label.gridy = 0;
				frame.getContentPane().add(label, gbc_label);
				
				//修改过的
				frame.setTitle("作物参数");
				
				
				//提示语标签
				JLabel label_4 = new JLabel("\u8BF7\u6B63\u786E\u8F93\u5165\u4EE5\u4E0B\u53C2\u6570\uFF1A");
				label_4.setFont(new Font("宋体", Font.PLAIN, 12));
				GridBagConstraints gbc_label_4 = new GridBagConstraints();
				gbc_label_4.anchor = GridBagConstraints.WEST;
				gbc_label_4.gridwidth = 2;
				gbc_label_4.insets = new Insets(0, 0, 5, 5);
				gbc_label_4.gridx = 1;
				gbc_label_4.gridy = 1;
				frame.getContentPane().add(label_4, gbc_label_4);
				//控制区标签2
				String sql0 = "select name from ctrlzone_para ;";
				Connection conn = null;
				Statement stmt = null;
				ResultSet rs = null;
				try {
					conn = MyDAO.getConnection();
				} catch (Exception e) {
					e.printStackTrace();
				}
					stmt = conn.createStatement();
				
				
					rs = stmt.executeQuery(sql0);
				if(rs.next()){
					crop.setCtrlzone_name(rs.getString(1));
				JLabel label_3 = new JLabel(rs.getString(1));
				GridBagConstraints gbc_label_3 = new GridBagConstraints();
				gbc_label_3.insets = new Insets(0, 0, 5, 5);
				gbc_label_3.gridx = 5;
				gbc_label_3.gridy = 1;
				frame.getContentPane().add(label_3, gbc_label_3);
				}
				//作物读取
						 ArrayList crop_kind=cropkind.getCrop_kind();
						final DefaultComboBoxModel defaultComboBoxModel=new DefaultComboBoxModel();
						
						for(int i=0;i<crop_kind.size();i++)
						{
							if(i==0||crop_kind.get(i)!=null){
								defaultComboBoxModel.addElement(crop_kind.get(i));
						}
						}
						defaultComboBoxModel.addElement("自定义");
						
						//土壤水分胁迫函数形参值Y读取
						final ArrayList soilWxp_Y=soilWxp.getSoilWxp_Y();
						final DefaultComboBoxModel defaultComboBoxModel_1=new DefaultComboBoxModel();
						for(int i=0;i<soilWxp_Y.size();i++)
						{
							if(i==0||soilWxp_Y.get(i)!=null){
								defaultComboBoxModel_1.addElement(soilWxp_Y.get(i));
						}
						}
						defaultComboBoxModel_1.addElement("自定义");
						//控制区标签1
						JLabel label_2 = new JLabel("\u5F53\u524D\u63A7\u5236\u533A:");
						GridBagConstraints gbc_label_2 = new GridBagConstraints();
						gbc_label_2.insets = new Insets(0, 0, 5, 5);
						gbc_label_2.gridx = 4;
						gbc_label_2.gridy = 1;
						frame.getContentPane().add(label_2, gbc_label_2);
						
						//作物种类标签
						JLabel label_7 = new JLabel("\u4F5C\u7269\u79CD\u7C7B\uFF1A");
						GridBagConstraints gbc_label_7 = new GridBagConstraints();
						gbc_label_7.anchor = GridBagConstraints.WEST;
						gbc_label_7.insets = new Insets(0, 0, 5, 5);
						gbc_label_7.gridx = 1;
						gbc_label_7.gridy = 2;
						frame.getContentPane().add(label_7, gbc_label_7);
						frame.getContentPane().add(label_7, gbc_label_7);
				
				
				//作物种类值选择
				JComboBox comboBox = new JComboBox();// 作物种类值选择
				comboBox.setFont(new Font("宋体", Font.PLAIN, 12));
				comboBox.setEditable(true);
				comboBox.setModel(defaultComboBoxModel);
				GridBagConstraints gbc_comboBox = new GridBagConstraints();
				gbc_comboBox.anchor = GridBagConstraints.WEST;
				gbc_comboBox.insets = new Insets(0, 0, 5, 5);
				gbc_comboBox.gridx = 2;
				gbc_comboBox.gridy = 2;
				frame.getContentPane().add(comboBox, gbc_comboBox);
				 //crop.setName((String) defaultComboBoxModel.getSelectedItem());
				
				 
				//萎焉点基质势标签
				JLabel lblhwcm = new JLabel("\u840E\u7109\u70B9\u57FA\u8D28\u52BFhw:");
				lblhwcm.setFont(new Font("宋体", Font.PLAIN, 12));
				GridBagConstraints gbc_lblhwcm = new GridBagConstraints();
				gbc_lblhwcm.anchor = GridBagConstraints.WEST;
				gbc_lblhwcm.insets = new Insets(0, 0, 5, 5);
				gbc_lblhwcm.gridx = 4;
				gbc_lblhwcm.gridy = 3;
				frame.getContentPane().add(lblhwcm, gbc_lblhwcm);
				
				//萎焉点基质势值
				 textField_0 = new TipsTextField("cm");
				 textField_0.setFont(new Font("宋体", Font.PLAIN, 12));
				 GridBagConstraints gbc_textField = new GridBagConstraints();
				 gbc_textField.anchor = GridBagConstraints.WEST;
				 gbc_textField.insets = new Insets(0, 0, 5, 5);
				 gbc_textField.gridx = 5;
				 gbc_textField.gridy = 3;
				 frame.getContentPane().add(textField_0, gbc_textField);
				 textField_0.setColumns(10);
				// textField_0.setToolTipText("cm");
				//crop.setWilt_jzs(textField_0.getText());
				
				//种植日期标签
				JLabel label_5 = new JLabel("\u79CD\u690D\u65E5\u671F\uFF08*\u5E74*\u6708*\u65E5\uFF09");
				GridBagConstraints gbc_label_5 = new GridBagConstraints();
				gbc_label_5.anchor = GridBagConstraints.WEST;
				gbc_label_5.insets = new Insets(0, 0, 5, 5);
				gbc_label_5.gridx = 1;
				gbc_label_5.gridy = 4;
				frame.getContentPane().add(label_5, gbc_label_5);
				 Calendar cal = Calendar.getInstance();
					 Calendar1 ser = Calendar1.getInstance();
				
				
				// 种植日期
				// 种植日期时间值
				textField_1 = new JTextField();
				//textField_1 .setText(cal.get(Calendar.YEAR)+"-0"+(cal.get(Calendar.MONTH)+1)+"-"+cal.get(Calendar.DATE));
				textField_1.setFont(new Font("宋体", Font.PLAIN, 12));
				textField_1.setBackground(Color.WHITE);
				final GridBagConstraints gbc_textField_1 = new GridBagConstraints();
				gbc_textField_1.anchor = GridBagConstraints.WEST;
				gbc_textField_1.insets = new Insets(0, 0, 5, 5);
				gbc_textField_1.gridx = 2;
				gbc_textField_1.gridy = 4;
				//frame.getContentPane().add(textField_1, gbc_textField_1);
				textField_1.setColumns(10);
				ser.register(textField_1);
				frame.getContentPane().add(textField_1, gbc_textField_1);
				//crop.setSoilWjzs_up(textField_2.getText());
				
				//最大扎根深度总标签
				JLabel lbllr = new JLabel("\u6700\u5927\u624E\u6839\u6DF1\u5EA6Lr:");
				GridBagConstraints gbc_lbllr = new GridBagConstraints();
				gbc_lbllr.insets = new Insets(0, 0, 5, 5);
				gbc_lbllr.gridx = 4;
				gbc_lbllr.gridy = 5;
				frame.getContentPane().add(lbllr, gbc_lbllr);
				
				//最适土壤水基质势上限标签1
				JLabel label_6= new JLabel("\u6700\u9002\u4F5C\u7269\u751F\u957F\u571F\u58E4");
				GridBagConstraints gbc_label_6 = new GridBagConstraints();
				gbc_label_6.anchor = GridBagConstraints.WEST;
				gbc_label_6.insets = new Insets(0, 0, 5, 5);
				gbc_label_6.gridx = 1;
				gbc_label_6.gridy = 6;
				frame.getContentPane().add(label_6, gbc_label_6);
				
				//最大扎根深度a标签
				JLabel lblA = new JLabel("\u4E8C\u6B21\u9879\u7CFB\u6570a");
				GridBagConstraints gbc_lblA = new GridBagConstraints();
				gbc_lblA.insets = new Insets(0, 0, 5, 5);
				gbc_lblA.gridx = 4;
				gbc_lblA.gridy = 6;
				frame.getContentPane().add(lblA, gbc_lblA);
				
				
				//最大扎根深度a值
				textField_5 = new TipsTextField("cm");
				textField_5.setFont(new Font("宋体", Font.PLAIN, 12));
				GridBagConstraints gbc_textField_5 = new GridBagConstraints();
				gbc_textField_5.anchor = GridBagConstraints.WEST;
				gbc_textField_5.insets = new Insets(0, 0, 5, 5);
				gbc_textField_5.gridx = 5;
				gbc_textField_5.gridy = 6;
				frame.getContentPane().add(textField_5, gbc_textField_5);
				textField_5.setColumns(10);
				//textField_5.setToolTipText("cm");
				
				//最适土壤水基质势上限标签2
				JLabel lblhhcm = new JLabel("\u6C34\u57FA\u8D28\u52BF\u4E0A\u9650hH:");
				GridBagConstraints gbc_lblhhcm = new GridBagConstraints();
				gbc_lblhhcm.anchor = GridBagConstraints.WEST;
				gbc_lblhhcm.insets = new Insets(0, 0, 5, 5);
				gbc_lblhhcm.gridx = 1;
				gbc_lblhhcm.gridy = 7;
				frame.getContentPane().add(lblhhcm, gbc_lblhhcm);
				
				//最适土壤水基质势上限值
				textField_2 = new TipsTextField("cm");
				textField_2.setFont(new Font("宋体", Font.PLAIN, 12));
				GridBagConstraints gbc_textField_2 = new GridBagConstraints();
				gbc_textField_2.anchor = GridBagConstraints.WEST;
				gbc_textField_2.insets = new Insets(0, 0, 5, 5);
				gbc_textField_2.gridx = 2;
				gbc_textField_2.gridy = 7;
				frame.getContentPane().add(textField_2, gbc_textField_2);
				textField_2.setColumns(10);
				//textField_2.setToolTipText("cm");
				
				//最大扎根深度b标签
				JLabel lblSdfdffgd = new JLabel("\u4E00\u6B21\u9879\u7CFB\u6570b");
				GridBagConstraints gbc_lblSdfdffgd = new GridBagConstraints();
				gbc_lblSdfdffgd.insets = new Insets(0, 0, 5, 5);
				gbc_lblSdfdffgd.gridx = 4;
				gbc_lblSdfdffgd.gridy = 7;
				frame.getContentPane().add(lblSdfdffgd, gbc_lblSdfdffgd);
				
				//最大扎根深度b值
				textField_6 = new TipsTextField("cm");
				textField_6.setFont(new Font("宋体", Font.PLAIN, 12));
				GridBagConstraints gbc_textField_6 = new GridBagConstraints();
				gbc_textField_6.anchor = GridBagConstraints.WEST;
				gbc_textField_6.insets = new Insets(0, 0, 5, 5);
				gbc_textField_6.gridx = 5;
				gbc_textField_6.gridy = 7;
				frame.getContentPane().add(textField_6, gbc_textField_6);
				textField_6.setColumns(10);
				//textField_6.setToolTipText("cm");
				//crop.setSoilWjzs_low(textField_3.getText());
				//最大扎根深度c标签
				JLabel lblC = new JLabel("\u5E38\u6570\u9879\u7CFB\u6570c");
				GridBagConstraints gbc_lblC = new GridBagConstraints();
				gbc_lblC.insets = new Insets(0, 0, 5, 5);
				gbc_lblC.gridx = 4;
				gbc_lblC.gridy = 8;
				frame.getContentPane().add(lblC, gbc_lblC);
				
		        //最大扎根深度c值
				textField_7 = new TipsTextField("cm");
				textField_7.setFont(new Font("宋体", Font.PLAIN, 12));
				GridBagConstraints gbc_textField_7 = new GridBagConstraints();
				gbc_textField_7.anchor = GridBagConstraints.WEST;
				gbc_textField_7.insets = new Insets(0, 0, 5, 5);
				gbc_textField_7.gridx = 5;
				gbc_textField_7.gridy = 8;
				frame.getContentPane().add(textField_7, gbc_textField_7);
				textField_7.setColumns(10);
				//textField_7.setToolTipText("cm");
				
				//最适土壤水基质势下限标签1
				JLabel label_3 = new JLabel("\u6700\u9002\u4F5C\u7269\u751F\u957F\u571F\u58E4");
				GridBagConstraints gbc_label_3 = new GridBagConstraints();
				gbc_label_3.anchor = GridBagConstraints.WEST;
				gbc_label_3.insets = new Insets(0, 0, 5, 5);
				gbc_label_3.gridx = 1;
				gbc_label_3.gridy = 9;
				frame.getContentPane().add(label_3, gbc_label_3);
				//最适土壤水基质势下限标签2
				JLabel lblhhcm_1 = new JLabel("\u6C34\u57FA\u8D28\u52BF\u4E0B\u9650hH:");
				GridBagConstraints gbc_lblhhcm_1 = new GridBagConstraints();
				gbc_lblhhcm_1.anchor = GridBagConstraints.WEST;
				gbc_lblhhcm_1.insets = new Insets(0, 0, 5, 5);
				gbc_lblhhcm_1.gridx = 1;
				gbc_lblhhcm_1.gridy = 10;
				frame.getContentPane().add(lblhhcm_1, gbc_lblhhcm_1);
				
				//最适土壤水基质势下限值
				textField_3 = new TipsTextField("cm");
				textField_3.setFont(new Font("宋体", Font.PLAIN, 12));
				textField_3.setColumns(10);
				GridBagConstraints gbc_textField_3 = new GridBagConstraints();
				gbc_textField_3.anchor = GridBagConstraints.WEST;
				gbc_textField_3.insets = new Insets(0, 0, 5, 5);
				gbc_textField_3.gridx = 2;
				gbc_textField_3.gridy = 10;
				frame.getContentPane().add(textField_3, gbc_textField_3);
				//textField_3.setToolTipText("cm");
				
				//土壤水分胁迫函数形参标签
				JLabel lblNewLabel = new JLabel("\u571F\u58E4\u6C34\u5206\u80C1\u8FEB\u51FD\u6570\u5F62\u53C2Y\uFF1A");
				GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
				gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
				gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
				gbc_lblNewLabel.gridx = 1;
				gbc_lblNewLabel.gridy = 12;
				frame.getContentPane().add(lblNewLabel, gbc_lblNewLabel);
				
				
				//土壤水分胁迫函数形参值Y下拉框
				JComboBox comboBox_1 = new JComboBox();
				comboBox_1.setEditable(true);
				comboBox_1.setFont(new Font("宋体", Font.PLAIN, 12));
				comboBox_1.setModel(defaultComboBoxModel_1);
				GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
				gbc_comboBox_1.anchor = GridBagConstraints.WEST;
				gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
				gbc_comboBox_1.gridx = 2;
				gbc_comboBox_1.gridy = 12;
				frame.getContentPane().add(comboBox_1, gbc_comboBox_1);
				final ArrayList crop_kind1=crop_kind;
				
				
				//crop.setSoilWxp_Y(textField_4.getText());
				//确定按钮
				JButton button_1 = new JButton("提交");
				button_1.setFont(new Font("宋体", Font.PLAIN, 12));
				button_1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						Connection conn = null;
						try {
							conn = MyDAO.getConnection();
						} catch (Exception e1) {
							e1.printStackTrace();
						}
						//插入作物
						for(int i=0;i<crop_kind1.size();i++)
						{
							if(i==0||crop_kind1.get(i)!=null){
								if(defaultComboBoxModel.getSelectedItem()==crop_kind1.get(i)){
									flag=0;
									break;
								}
								else{
									flag=1;
								}
						}
						}
						if(flag==1){
							 String sql1="insert into crop_kind (name) values('"+defaultComboBoxModel.getSelectedItem()+"');";
							   try {
								   java.sql.PreparedStatement ptmt=conn.prepareStatement(sql1);
								   ptmt.execute();
							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
						}
						flag=0;
						//插入土壤水分胁迫函数形参值Y
						for(int i=0;i<soilWxp_Y.size();i++)
						{
							if(i==0||soilWxp_Y.get(i)!=null){
								if(defaultComboBoxModel_1.getSelectedItem()==soilWxp_Y.get(i)){
									flag=0;
									break;
								}
								else{
									flag=1;
								}
						}
						}
						if(flag==1){
							 String sql1="insert into SoilWxp_Y (soilWxp_Y) values('"+defaultComboBoxModel_1.getSelectedItem()+"');";
							   try {
								   java.sql.PreparedStatement ptmt=conn.prepareStatement(sql1);
								   ptmt.execute();
							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
						}
						flag=0;
						crop.setId(cropkind.getId((String)defaultComboBoxModel.getSelectedItem()));
						//修改过的
						String[] time =textField_1.getText().split("-");
						crop.setDate(time[0]+"-"+time[1]+"-"+time[2]);
						crop.setName((String) defaultComboBoxModel.getSelectedItem());
						crop.setWilt_jzs(textField_0.getText());
						crop.setSoilWjzs_up(textField_2.getText());
						crop.setSoilWjzs_low(textField_3.getText());
						crop.setSoilWxp_Y((String) defaultComboBoxModel_1.getSelectedItem());
						
						Calendar c=Calendar.getInstance();
					
						//System.out.println(c.get(Calendar.YEAR)+""+c.get(Calendar.MONTH)+""+c.get(Calendar.DATE));
						//计算天数
						int year=Integer.parseInt(time[0]);
						int days=0;
						for(int i=Integer.parseInt(time[1]);i<=12;i++){
						      if(year==c.get(Calendar.YEAR)&&i==c.get(Calendar.MONTH)+1){
						     days+=(c.get(Calendar.DATE)-Integer.parseInt(time[2]));
						  
						break;
						}
						else{
							
						if(i!=2){
						if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
						days+=31;
						}
						else{
						days+=30;
						}
						}
						else{
						if(year%4==0&&year%100!=0||year%400==0){
						days+=29;
						}
						else{
						days+=28;
						}
						}
						}
						if(i==12){
						i=1;
						year++;
						}
						}
						crop.setMaxRootDepth(Integer.parseInt(textField_5.getText())*days*days+Integer.parseInt(textField_6.getText())*days+Integer.parseInt(textField_7.getText())+"");
						 //crop.setSoilWxp_Y(soilWxp_Y);
						String sql2="insert into tra_crop_para1  values('"+crop.getId()+"','"+crop.getDate()+"','"+crop.getName()+"','"+crop.getCtrlzone_name()+"','"+crop.getMaxRootDepth()+"','"+crop.getWilt_jzs()+"','"+crop.getSoilWjzs_up()+"','"+crop.getSoilWjzs_low()+"','"+crop.getSoilWxp_Y()+"');";
						   try {
							   java.sql.PreparedStatement ptmt=conn.prepareStatement(sql2);
							   ptmt.execute();
						} catch (SQLException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						   JLabel l = new JLabel("提交成功");
							l.setFont(new Font("宋体", Font.PLAIN, 12));
							JOptionPane.showMessageDialog(null, l);
							
					}
				});
				
				rs.close();
				stmt.close();
				conn.close();
				
				
				
				GridBagConstraints gbc_button = new GridBagConstraints();
				gbc_button.anchor = GridBagConstraints.EAST;
				gbc_button.insets = new Insets(0, 0, 5, 5);
				gbc_button.gridx = 3;
				gbc_button.gridy = 14;
				frame.getContentPane().add(button_1, gbc_button);
				
				
				JButton button_2 = new JButton("重置");
				button_2.setFont(new Font("宋体", Font.PLAIN, 12));
				button_2.addActionListener(new ActionListener(){

					@Override
					public void actionPerformed(ActionEvent e) {
						// TODO Auto-generated method stub
						textField_0.setText("");  //萎焉点基质势值
						textField_1.setText("");//种植日期年值
						textField_2.setText("");//最适土壤水基质势上限值
						textField_3.setText("");//最适土壤水基质势下限值
						textField_5.setText("");//最大扎根深度a值
						textField_6.setText("");//最大扎根深度b值
						textField_7.setText("");//最大扎根深度c值
						
						
					}
					
				});
				GridBagConstraints gbc_button_1 = new GridBagConstraints();
				gbc_button_1.anchor = GridBagConstraints.WEST;
				gbc_button_1.insets = new Insets(0, 0, 5, 5);
				gbc_button_1.gridx = 4;
				gbc_button_1.gridy = 14;
				frame.getContentPane().add(button_2, gbc_button_1);
				
				frame.setVisible(true);
				frame.pack();
				frame.setBackground(Color.WHITE);	
				frame.setLocationRelativeTo(null);
				//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

}
